<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: RssListener.cfc 1175 2007-06-25 00:59:44Z pfarrell $

Notes:
This listener is autowired by ColdSpring.
The vast majority of the RSS functionality is borrowed liberally from Ray Camden's BlogCFC (http://www.blogcfc.com).
THANKS RAY!!!!
--->
<cfcomponent
	displayname="RssListener"
	extends="MachII.framework.Listener"
	output="false"
	hint="RssListener for MachBlog">

	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="configure" access="public" output="false" returntype="void">
		<!--- don't need anything here for now --->
	</cffunction>
	
	<cffunction name="getRssService" access="public" output="false" returntype="machblog.org.machblog.rss.RssService">
		<cfreturn variables.rssService />
	</cffunction>
	<cffunction name="setRssService" access="public" output="false" returntype="void" hint="dependency: injected">
		<cfargument name="rssService" type="machblog.org.machblog.rss.RssService" required="true" />
		<cfset variables.rssService = arguments.rssService />
	</cffunction>

	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="getBlogRss" access="public" output="false" returntype="string" 
			hint="Returns the RSS for the entire blog.  By default returns the same entries displayed on the home page.">
		<cfreturn getRssService().getBlogRss(getProperty("numEntriesForRss"), getProperty("appName"), getProperty("blogUrl"), 
												getProperty("blogDescription"), replace(lcase(getProperty("rbLocale")), "_", "-", "one"), 
												"MachBlog", getProperty("emailAuthor"), getProperty("emailWebmaster"), 
												getModuleName()) />
	</cffunction>
	
	<cffunction name="getCategoryRss" access="public" output="false" returntype="string" 
			hint="Returns the RSS for a particular category.  By default returns the most recent 20 entries.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		
		<cfreturn getRssService().getCategoryRss(arguments.event.getArg("categoryId"), 
													#getProperty("resourceBundleService").getResourceBundle().getResource("category")# & ": " & #arguments.event.getArg("categoryName")#, 
													getProperty("appName"), getProperty("blogUrl"), 
													getProperty("blogDescription"), 
													replace(lcase(getProperty("rbLocale")), "_", "-", "one"), 
													"MachBlog", getProperty("emailAuthor"), 
													getProperty("emailWebmaster"),
													getModuleName()) />
	</cffunction>
	
	<cffunction name="getModuleName" access="private" returntype="string" output="false"
		hint="Gets the module name if Mach-II 1.5+">
		
		<cfset var name = "" />
		<cfset var ap = getAppManager() />
		
		<cfif StructKeyExists(ap, "getModuleName")>
			<cfset name = ap.getModuleName() />
		</cfif>
		
		<cfreturn name />
	</cffunction>
	
</cfcomponent>